import com.sun.jmx.snmp.SnmpUnknownMsgProcModelException;

public class Day5 {

//    public static int guessNumber(int n) {
//
//        int front = 1;
//        int tail = n;
//        int mid = (front + tail) / 2;
//
//        while (guess(mid) != 0) {
//
//            if (guess(mid) == 1) {
//                tail = mid;
//                mid = (front + tail) / 2;
//            } else {
//                front = mid;
//                mid = (front + tail) / 2;
//            }
//
//        }
//
//        return mid;
//
//    }

    public static void main(String[] args) {



//        System.out.println(addDigits(38));

    }

    public static int addDigits(int num) {

        while (num / 10 != 0) {

            int sum = 0;
            for (; num != 0; num /= 10) {
                int a = num % 10;
                sum += a;
            }
            num = sum;

        }

        return num;

    }

}
